<%# $Id: index.rhtml 127 2009-06-01 16:40:35Z toshiyuki.ando1971 $
# To change this template, choose Tools | Templates
# and open the template in the editor.
%>
<style type="text/css">
<!-- div#content {
  background-image: url("<%="#{@settings.url}images/hudson.png"%>");
  background-position: left bottom;
  background-attachment: fixed;
  background-repeat: no-repeat;
}// -->
</style>
<h2><%=l(:label_job_list)%></h2>

<% if @jobs.length == 0 %>
  <div class="nodata"><%=l(:notice_no_jobs)%></div>
<% else %>
  <div class="flash notice" id="info" style="display:none;">build accepted</div>
  <div class="flash error" id="error" style="display:none;">build failure</div>
  <div id="remote-debug" style="display:none;"></div>

  <% @jobs.each do |job|%>
    <div class="contextual">
    <%= link_to_remote_if_authorized '[Build Now]',
          :url => {:action => 'build', :id => @project, :name => job[:name]},
          :update => {:success => 'remote-debug', :failure => 'remote-debug'},
          :success => "if(request.responseText.indexOf('build_accepted') > 0 ){Element.show('info');Element.hide('error');}else{Element.show('error');Element.hide('info');}",
          :failure => "Element.show('error');Element.hide('info');"
    %>
    </div>

    <div class="contextual latest-build" id='latest-build-<%=job[:name]%>'>
      <%=job[:latestBuild][:error] if "" != job[:latestBuild][:error]%>
      <% if "" == job[:latestBuild][:error] %>
        <% if "" != job[:latestBuild][:number] %>
          <%=image_tag 'document.png', :class=>'icon-build-history', :id=>"build-history-#{job[:name]}"%>
          <%=link_to "##{job[:latestBuild][:number]}", job[:latestBuild][:url]%>
          <%=content_tag("span", job[:latestBuild][:result], :class => "result #{job[:latestBuild][:result].downcase}") if "true" != job[:latestBuild][:building] && "" != job[:latestBuild][:result]%>
          <%=content_tag("span", l(:notice_building), :class => "result") if "true" == job[:latestBuild][:building] %>
          <%=content_tag("span", job[:latestBuild][:timestamp].strftime("%Y/%m/%d %H:%M:%S")) %>
        <% end %>
        <%=l(:notice_no_builds) if "" == job[:latestBuild][:number]%>
      <% end %>
    </div>

    <div class="job-state">
    <h3 class="icon icon-<%=job[:state]%>"><%=link_to job[:name], job[:url]%></h3>
    <% if @settings[:show_compact] != true %>
      <div class="wiki">
        <%= textilizable job[:description] -%>
      </div>

      <ul>
        <% job[:healthReport].each do |report| %>
          <%="<li>#{link_to(report[:description], report[:url])} #{report[:score]}%" if report[:url] != ""%>
          <%="<li>#{report[:description]} #{report[:score]}%" if report[:url] == ""%>
        <% end %>
      </ul>
    <% end %>
    </div>
  <% end %>

  <div id="build-history" style="display:none;"></div>
  <%= javascript_tag "new BuildHistory('#{url_for(:controller => 'hudson', :action => 'history', :id=>@project)}')" %>
<% end %>

<% content_for :sidebar do %>
  <%= render :partial => 'hudson_sidebar' %>
<% end %>

<style type="text/css"></style>

<% content_for :header_tags do %>
  <%= stylesheet_link_tag "hudson.css", :plugin => "redmine_hudson", :media => "screen" %>
  <%= javascript_include_tag 'build_history', :plugin => "redmine_hudson" %>
<% end %>
